library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)
library(mlbench)
library(psych)
library(whitening)
library("vioplot")
library("rpart")
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
mlBench library
Newman, D.J. & Hettich, S. & Blake, C.L. & Merz, C.J. (1998). UCI Repository of machine learning databases [http://www.ics.uci.edu/~mlearn/MLRepository.html]. Irvine, CA: University of California, Department of Information and Computer Science.
#data(PimaIndiansDiabetes)
#pander::pander(table(PimaIndiansDiabetes$diabetes))
#PimaIndiansDiabetes$diabetes <- 1*(PimaIndiansDiabetes$diabetes=="pos")
data("PimaIndiansDiabetes2", package = "mlbench")
PimaIndiansDiabetes <- PimaIndiansDiabetes2[complete.cases(PimaIndiansDiabetes2),]
#data(PimaIndiansDiabetes)
#PimaIndiansDiabetes <- PimaIndiansDiabetes[complete.cases(PimaIndiansDiabetes),]
PimaIndiansDiabetes_mat <- as.data.frame(model.matrix(diabetes~.*.,PimaIndiansDiabetes)[,-1])
fnames <- colnames(PimaIndiansDiabetes_mat)
fnames <- str_replace_all(fnames," ","_")
fnames <- str_replace_all(fnames,"/","_")
fnames <- str_replace_all(fnames,":","_x_")
colnames(PimaIndiansDiabetes_mat) <- fnames
whohasx <- str_detect(fnames,"_x_")
PimaIndiansDiabetes_mat[,whohasx] <- sqrt(PimaIndiansDiabetes_mat[,whohasx])
pander::pander(table(PimaIndiansDiabetes$diabetes))
| neg | pos |
|---|---|
| 262 | 130 |
PimaIndiansDiabetes_mat$diabetes <- 1*(PimaIndiansDiabetes$diabetes=="pos")
studyName <- "Diabetes"
dataframe <- PimaIndiansDiabetes_mat
outcome <- "diabetes"
thro <- 0.6
TopVariables <- 5
cexheat = 0.35
Some libraries
library(psych)
library(whitening)
library("vioplot")
library("rpart")
pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
| rows | col |
|---|---|
| 392 | 36 |
pander::pander(table(dataframe[,outcome]))
| 0 | 1 |
|---|---|
| 262 | 130 |
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
largeSet <- length(varlist) > 1500
Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns
### Some global cleaning
sdiszero <- apply(dataframe,2,sd) > 1.0e-16
dataframe <- dataframe[,sdiszero]
varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
dataframe <- dataframe[,tokeep]
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
iscontinous <- sapply(apply(dataframe,2,unique),length) >= 5 ## Only variables with enough samples
dataframeScaled <- FRESAScale(dataframe,method="OrderLogit")$scaledData
numsub <- nrow(dataframe)
if (numsub > 1000) numsub <- 1000
if (!largeSet)
{
hm <- heatMaps(data=dataframeScaled[1:numsub,],
Outcome=outcome,
Scale=TRUE,
hCluster = "row",
xlab="Feature",
ylab="Sample",
srtCol=45,
srtRow=45,
cexCol=cexheat,
cexRow=cexheat
)
par(op)
}
The heat map of the data
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
#cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
cormat <- cor(dataframe[,varlist],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Original Correlation",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.9815674
DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#>
#> pregnant_x_pressure
#> pregnant glucose pressure triceps insulin mass
#> 0.86111111 0.19444444 0.02777778 0.69444444 0.77777778 0.25000000
#>
#> Included: 36 , Uni p: 0.004166667 , Base Size: 1 , Rcrit: 0.1330839
#>
#>
1 <R=0.982,thr=0.950>, Top: 4< 4 >[Fa= 4 ]( 4 , 7 , 0 ),<|><>Tot Used: 11 , Added: 7 , Zero Std: 0 , Max Cor: 0.945
#>
2 <R=0.945,thr=0.900>, Top: 4< 2 >[Fa= 6 ]( 4 , 8 , 4 ),<|><>Tot Used: 20 , Added: 8 , Zero Std: 0 , Max Cor: 0.939
#>
3 <R=0.939,thr=0.900>, Top: 1< 1 >[Fa= 7 ]( 1 , 1 , 6 ),<|><>Tot Used: 21 , Added: 1 , Zero Std: 0 , Max Cor: 0.898
#>
4 <R=0.898,thr=0.800>, Top: 7< 3 >[Fa= 9 ]( 7 , 14 , 7 ),<|><>Tot Used: 33 , Added: 14 , Zero Std: 0 , Max Cor: 0.974
#>
5 <R=0.974,thr=0.950>, Top: 2< 1 >[Fa= 11 ]( 2 , 2 , 9 ),<|><>Tot Used: 33 , Added: 2 , Zero Std: 0 , Max Cor: 0.930
#>
6 <R=0.930,thr=0.900>, Top: 2< 1 >[Fa= 11 ]( 2 , 2 , 11 ),<|><>Tot Used: 33 , Added: 2 , Zero Std: 0 , Max Cor: 0.873
#>
7 <R=0.873,thr=0.800>, Top: 4< 1 >[Fa= 11 ]( 3 , 5 , 11 ),<|><>Tot Used: 33 , Added: 5 , Zero Std: 0 , Max Cor: 0.894
#>
8 <R=0.894,thr=0.800>, Top: 1< 2 >[Fa= 11 ]( 1 , 2 , 11 ),<|><>Tot Used: 33 , Added: 2 , Zero Std: 0 , Max Cor: 0.793
#>
9 <R=0.793,thr=0.700>, Top: 9< 3 >[Fa= 11 ]( 7 , 11 , 11 ),<|><>Tot Used: 36 , Added: 11 , Zero Std: 0 , Max Cor: 0.918
#>
10 <R=0.918,thr=0.900>, Top: 1< 1 >[Fa= 11 ]( 1 , 1 , 11 ),<|><>Tot Used: 36 , Added: 1 , Zero Std: 0 , Max Cor: 0.832
#>
11 <R=0.832,thr=0.800>, Top: 4< 2 >[Fa= 11 ]( 4 , 5 , 11 ),<|><>Tot Used: 36 , Added: 5 , Zero Std: 0 , Max Cor: 0.767
#>
12 <R=0.767,thr=0.700>, Top: 2< 1 >[Fa= 11 ]( 2 , 2 , 11 ),<|><>Tot Used: 36 , Added: 2 , Zero Std: 0 , Max Cor: 0.740
#>
13 <R=0.740,thr=0.700>, Top: 1< 1 >[Fa= 12 ]( 1 , 1 , 11 ),<|><>Tot Used: 36 , Added: 1 , Zero Std: 0 , Max Cor: 0.679
#>
14 <R=0.679,thr=0.600>, Top: 4< 3 >[Fa= 13 ]( 4 , 6 , 12 ),<|><>Tot Used: 36 , Added: 6 , Zero Std: 0 , Max Cor: 0.784
#>
15 <R=0.784,thr=0.700>, Top: 1< 1 >[Fa= 13 ]( 1 , 1 , 13 ),<|><>Tot Used: 36 , Added: 1 , Zero Std: 0 , Max Cor: 0.685
#>
16 <R=0.685,thr=0.600>, Top: 1< 1 >[Fa= 13 ]( 1 , 1 , 13 ),<|><>Tot Used: 36 , Added: 1 , Zero Std: 0 , Max Cor: 0.625
#>
17 <R=0.625,thr=0.600>, Top: 1< 1 >[Fa= 13 ]( 1 , 1 , 13 ),<|><>Tot Used: 36 , Added: 1 , Zero Std: 0 , Max Cor: 0.598
#>
18 <R=0.598,thr=0.600>
#>
[ 18 ], 0.5981508 Decor Dimension: 36 Nused: 36 . Cor to Base: 27 , ABase: 36 , Outcome Base: 0
#>
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]
pander::pander(sum(apply(dataframe[,varlist],2,var)))
24490
pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))
4922
pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))
3.45
pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))
3.09
varratio <- attr(DEdataframe,"VarRatio")
pander::pander(tail(varratio))
| La_mass_x_age | La_pregnant_x_mass | La_mass | La_glucose_x_triceps | La_pregnant_x_age | La_glucose_x_age |
|---|---|---|---|---|---|
| 0.0186 | 0.0184 | 0.0138 | 0.0133 | 0.0109 | 0.00587 |
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
UPLTM <- attr(DEdataframe,"UPLTM")
gplots::heatmap.2(1.0*(abs(UPLTM)>0),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
}
Displaying the features associations
par(op)
#if ((ncol(dataframe) < 1000) && (ncol(dataframe) > 10))
#{
# DEdataframeB <- ILAA(dataframe,verbose=TRUE,thr=thro,bootstrap=30)
transform <- attr(DEdataframe,"UPLTM") != 0
tnames <- colnames(transform)
colnames(transform) <- str_remove_all(colnames(transform),"La_")
transform <- abs(transform*cor(dataframe[,rownames(transform)])) # The weights are proportional to the observed correlation
VertexSize <- attr(DEdataframe,"fscore") # The size depends on the variable independence relevance (fscore)
names(VertexSize) <- str_remove_all(names(VertexSize),"La_")
VertexSize <- 10*(VertexSize-min(VertexSize))/(max(VertexSize)-min(VertexSize)) # Normalization
VertexSize <- VertexSize[rownames(transform)]
rsum <- apply(1*(transform !=0),1,sum) + 0.01*VertexSize + 0.001*varratio[tnames]
csum <- apply(1*(transform !=0),2,sum) + 0.01*VertexSize + 0.001*varratio[tnames]
ntop <- min(10,length(rsum))
topfeatures <- unique(c(names(rsum[order(-rsum)])[1:ntop],names(csum[order(-csum)])[1:ntop]))
rtrans <- transform[topfeatures,]
csum <- (apply(1*(rtrans !=0),2,sum) > 1)
rtrans <- rtrans[,csum]
topfeatures <- unique(c(topfeatures,colnames(rtrans)))
print(ncol(transform))
#> [1] 36
transform <- transform[topfeatures,topfeatures]
print(ncol(transform))
#> [1] 35
if (ncol(transform)>100)
{
csum <- (apply(1*(transform !=0),2,sum) > 1) & (apply(1*(transform !=0),1,sum) > 1)
transform <- transform[csum,csum]
print(ncol(transform))
}
if (ncol(transform) < 150)
{
gplots::heatmap.2(transform,
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Red Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
VertexSize <- VertexSize[colnames(transform)]
gr <- graph_from_adjacency_matrix(transform,mode = "directed",diag = FALSE,weighted=TRUE)
gr$layout <- layout_with_fr
fc <- cluster_optimal(gr)
plot(fc, gr,
edge.width = 2*E(gr)$weight,
vertex.size=VertexSize,
edge.arrow.size=0.5,
edge.arrow.width=0.5,
vertex.label.cex=(0.15+0.05*VertexSize),
vertex.label.dist=0.5 + 0.05*VertexSize,
main="Top Feature Association")
}
par(op)
if (!largeSet)
{
cormat <- cor(DEdataframe[,varlistc],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Correlation after ILAA",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
par(op)
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.5981508
classes <- unique(dataframe[1:numsub,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
topvars <- univariate_BinEnsemble(dataframe,outcome)
lso <- LASSO_MIN(formula(paste(outcome,"~.")),dataframe,family="binomial")
topvars <- unique(c(names(topvars),lso$selectedfeatures))
pander::pander(head(topvars))
glucose, glucose_x_pressure, glucose_x_triceps, glucose_x_mass, glucose_x_age and insulin_x_age
# names(topvars)
#if (nrow(dataframe) < 1000)
#{
datasetframe.umap = umap(scale(dataframe[1:numsub,topvars]),n_components=2)
# datasetframe.umap = umap(dataframe[1:numsub,varlist],n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[1:numsub,outcome],col=raincolors[dataframe[1:numsub,outcome]+1])
#}
varlistcV <- names(varratio[varratio >= 0.025])
topvars <- univariate_BinEnsemble(DEdataframe[,varlistcV],outcome)
lso <- LASSO_MIN(formula(paste(outcome,"~.")),DEdataframe,family="binomial")
topvars <- unique(c(names(topvars),lso$selectedfeatures))
pander::pander(head(topvars))
La_insulin_x_pedigree, La_glucose_x_mass, glucose_x_insulin, La_glucose, La_pregnant_x_glucose and La_triceps_x_insulin
varlistcV <- varlistcV[varlistcV != outcome]
# DEdataframe[,outcome] <- as.numeric(DEdataframe[,outcome])
#if (nrow(dataframe) < 1000)
#{
datasetframe.umap = umap(scale(DEdataframe[1:numsub,topvars]),n_components=2)
# datasetframe.umap = umap(DEdataframe[1:numsub,varlistcV],n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After ILAA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[1:numsub,outcome],col=raincolors[DEdataframe[1:numsub,outcome]+1])
#}
univarRAW <- uniRankVar(varlist,
paste(outcome,"~1"),
outcome,
dataframe,
rankingTest="AUC")
univarDe <- uniRankVar(varlistc,
paste(outcome,"~1"),
outcome,
DEdataframe,
rankingTest="AUC",
)
univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")
##top variables
topvar <- c(1:length(varlist)) <= TopVariables
tableRaw <- univarRAW$orderframe[topvar,univariate_columns]
pander::pander(tableRaw)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| glucose_x_age | 71.3 | 14.04 | 55.5 | 11.26 | 0.000494 | 0.825 |
| glucose_x_mass | 71.4 | 9.81 | 58.9 | 9.73 | 0.706132 | 0.821 |
| glucose | 145.2 | 29.84 | 111.4 | 24.64 | 0.034320 | 0.806 |
| glucose_x_pressure | 102.8 | 14.77 | 86.9 | 13.16 | 0.257647 | 0.793 |
| glucose_x_triceps | 68.1 | 12.85 | 53.9 | 12.77 | 0.421846 | 0.784 |
topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]
pander::pander(finalTable)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| glucose_x_insulin | 167.20 | 60.56 | 116.02 | 51.83 | 0.009684 | 0.768 |
| La_insulin_x_pedigree | -6.72 | 1.93 | -5.56 | 1.32 | 0.038723 | 0.739 |
| La_glucose_x_mass | -4.77 | 1.92 | -3.47 | 1.69 | 0.000224 | 0.719 |
| La_glucose | 79.54 | 23.96 | 65.88 | 15.90 | 0.075929 | 0.686 |
| La_triceps_x_insulin | -32.45 | 8.44 | -27.75 | 6.34 | 0.070954 | 0.685 |
dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")
pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
| mean | total | fraction |
|---|---|---|
| 3.44 | 32 | 0.889 |
theCharformulas <- attr(dc,"LatentCharFormulas")
finalTable <- rbind(finalTable,tableRaw[topvar[!(topvar %in% topLAvar)],univariate_columns])
orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- theCharformulas[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]
Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")
finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
| DecorFormula | caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | RAWAUC | fscores | |
|---|---|---|---|---|---|---|---|---|---|
| glucose_x_age | NA | 71.29 | 14.04 | 55.49 | 11.26 | 0.000494 | 0.825 | 0.825 | NA |
| glucose_x_mass | NA | 71.37 | 9.81 | 58.90 | 9.73 | 0.706132 | 0.821 | 0.821 | NA |
| glucose | NA | 145.19 | 29.84 | 111.43 | 24.64 | 0.034320 | 0.806 | 0.806 | NA |
| glucose_x_pressure | NA | 102.83 | 14.77 | 86.94 | 13.16 | 0.257647 | 0.793 | 0.793 | NA |
| glucose_x_triceps | NA | 68.06 | 12.85 | 53.86 | 12.77 | 0.421846 | 0.784 | 0.784 | NA |
| glucose_x_insulin | NA | 167.20 | 60.56 | 116.02 | 51.83 | 0.009684 | 0.768 | 0.768 | 8 |
| La_insulin_x_pedigree | - (0.055)glucose_x_insulin + insulin_x_pedigree - (1.743)mass_x_pedigree | -6.72 | 1.93 | -5.56 | 1.32 | 0.038723 | 0.739 | 0.742 | -2 |
| La_glucose_x_mass | - (0.303)glucose + (0.924)age + glucose_x_mass - (1.853)mass_x_age | -4.77 | 1.92 | -3.47 | 1.69 | 0.000224 | 0.719 | 0.821 | -2 |
| La_glucose | + glucose - (0.393)glucose_x_insulin | 79.54 | 23.96 | 65.88 | 15.90 | 0.075929 | 0.686 | 0.806 | 5 |
| La_triceps_x_insulin | - (0.412)glucose_x_insulin + triceps_x_insulin - (1.229)triceps_x_mass | -32.45 | 8.44 | -27.75 | 6.34 | 0.070954 | 0.685 | 0.753 | -2 |
featuresnames <- colnames(dataframe)[colnames(dataframe) != outcome]
pc <- prcomp(dataframe[,iscontinous],center = TRUE,scale. = TRUE) #principal components
predPCA <- predict(pc,dataframe[,iscontinous])
PCAdataframe <- as.data.frame(cbind(predPCA,dataframe[,!iscontinous]))
colnames(PCAdataframe) <- c(colnames(predPCA),colnames(dataframe)[!iscontinous])
#plot(PCAdataframe[,colnames(PCAdataframe)!=outcome],col=dataframe[,outcome],cex=0.65,cex.lab=0.5,cex.axis=0.75,cex.sub=0.5,cex.main=0.75)
#pander::pander(pc$rotation)
PCACor <- cor(PCAdataframe[,colnames(PCAdataframe) != outcome])
gplots::heatmap.2(abs(PCACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "PCA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
EFAdataframe <- dataframeScaled
if (length(iscontinous) < 2000)
{
topred <- min(length(iscontinous),nrow(dataframeScaled),ncol(predPCA)/2)
if (topred < 2) topred <- 2
uls <- fa(dataframeScaled[,iscontinous],nfactors=topred,rotate="varimax",warnings=FALSE) # EFA analysis
predEFA <- predict(uls,dataframeScaled[,iscontinous])
EFAdataframe <- as.data.frame(cbind(predEFA,dataframeScaled[,!iscontinous]))
colnames(EFAdataframe) <- c(colnames(predEFA),colnames(dataframeScaled)[!iscontinous])
EFACor <- cor(EFAdataframe[,colnames(EFAdataframe) != outcome])
gplots::heatmap.2(abs(EFACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "EFA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
}
par(op)
par(xpd = TRUE)
dataframe[,outcome] <- factor(dataframe[,outcome])
rawmodel <- rpart(paste(outcome,"~."),dataframe,control=rpart.control(maxdepth=3))
pr <- predict(rawmodel,dataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(rawmodel,main="Raw",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(rawmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,dataframe[,outcome]==0))
}
pander::pander(table(dataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 220 | 42 |
| 1 | 31 | 99 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.814 | 0.772 | 0.851 |
| 3 | se | 0.762 | 0.679 | 0.832 |
| 4 | sp | 0.840 | 0.790 | 0.882 |
| 6 | diag.or | 16.728 | 9.933 | 28.171 |
par(op)
par(xpd = TRUE)
DEdataframe[,outcome] <- factor(DEdataframe[,outcome])
IDeAmodel <- rpart(paste(outcome,"~."),DEdataframe[,c(outcome,varlistcV)],control=rpart.control(maxdepth=3))
pr <- predict(IDeAmodel,DEdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(IDeAmodel,main="ILAA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(IDeAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,DEdataframe[,outcome]==0))
}
pander::pander(table(DEdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 218 | 44 |
| 1 | 30 | 100 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.811 | 0.769 | 0.849 |
| 3 | se | 0.769 | 0.687 | 0.839 |
| 4 | sp | 0.832 | 0.781 | 0.875 |
| 6 | diag.or | 16.515 | 9.809 | 27.805 |
par(op)
par(xpd = TRUE)
PCAdataframe[,outcome] <- factor(PCAdataframe[,outcome])
PCAmodel <- rpart(paste(outcome,"~."),PCAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(PCAmodel,PCAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(PCAmodel,main="PCA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(PCAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,PCAdataframe[,outcome]==0))
}
pander::pander(table(PCAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 217 | 45 |
| 1 | 23 | 107 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.827 | 0.785 | 0.863 |
| 3 | se | 0.823 | 0.746 | 0.884 |
| 4 | sp | 0.828 | 0.777 | 0.872 |
| 6 | diag.or | 22.434 | 12.902 | 39.007 |
par(op)
EFAdataframe[,outcome] <- factor(EFAdataframe[,outcome])
EFAmodel <- rpart(paste(outcome,"~."),EFAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(EFAmodel,EFAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(EFAmodel,main="EFA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(EFAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,EFAdataframe[,outcome]==0))
}
pander::pander(table(EFAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 244 | 18 |
| 1 | 56 | 74 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.811 | 0.769 | 0.849 |
| 3 | se | 0.569 | 0.480 | 0.656 |
| 4 | sp | 0.931 | 0.894 | 0.959 |
| 6 | diag.or | 17.913 | 9.916 | 32.357 |
par(op)